local skel = fk.CreateSkill{
  name = "lb__xifu",
}

Fk:loadTranslationTable{
["lb__xifu"] = "系缚",
[":lb__xifu"] = "出牌阶段，你造成伤害后可以令你与受伤者同时获得“承”或“负”；每回合结束时，若你或当前<a href=':lb__wennie'><font color='red'>〖问孽〗</font></a>选择的角色同时拥有“承”“负”，重置<a href=':lb__wennie'><font color='red'>〖问孽〗</font></a>。",

["#lb__xifu"] = "系缚：你可以与 %dest 获得“承”或“负”",

["$lb__xifu1"] = "束手就缚罢。",
["$lb__xifu2"] = "我代十王判罚。",
}

skel:addEffect(fk.Damage, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and player == target
  end,
  on_cost = function (self, event, target, player, data)
    local choice = player.room:askToChoice(player,{
      choices = {"@@lb__wennie_cheng", "@@lb__wennie_fu", "Cancel"},
      skill_name = skel.name,
      prompt = "#lb__xifu::"..data.to.id,
    })
    event:setCostData(self, {choice = choice})
    return choice ~= "Cancel"
  end,
  on_use = function(self, event, target, player, data)
    local mark = event:getCostData(self).choice
    player.room:setPlayerMark(player, mark, 1)
    player.room:setPlayerMark(data.to, mark, 1)
  end,
})

skel:addEffect(fk.TurnEnd, {
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and player:getMark("@lb__wennie") ~= 0 then
      local t = player:getMark("@lb__wennie")
      return (player:getMark("@@lb__wennie_cheng") > 0 and player:getMark("@@lb__wennie_fu") > 0) or
      (t:getMark("@@lb__wennie_cheng") > 0 and t:getMark("@@lb__wennie_fu") > 0)
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player:setSkillUseHistory("lb__wennie", 0, Player.HistoryGame)
  end,
})

return skel